﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<link>
		
		<title>jb-aptech毕业设计项目</TITLE>
<meta name="renderer" content="ie-comp">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="../../css/style.css" rel="stylesheet" type="text/css">
		<script src="../../script/common.js"></script>
		<!--<script src="../../script/validate.js"></script>-->
<!--<link rel="stylesheet" type="text/css" href="ExtJS/resources/css/ext-all.css">-->
<!--<script type="text/javascript" src="ExtJS/adapter/ext/ext-base.js"></script>-->
<!--<script type="text/javascript" src="ExtJS/ext-all.js"></script>-->
        <link rel="stylesheet" href="/css/bootstrap.min.css" type="text/css"></link>
        <script type="text/javascript" src="/js/jquery.min.js"></script>
        <script type="text/javascript" src="/js/bootstrap.min.js"></script>
        <script src="../../../js/vue.js"></script>
    </head>
	<script type="text/javascript">
		function myAdd(){
			document.sysRightForm.submit();
		}
	</script>
	<body>
		<div class="page_title">
			权限管理 > 权限管理 > 权限查询
		</div>
		<div id="list">
		<form name="sysRightForm" method="post" action="/CRM/sysRight.do?method=searchSysRight">
			
			<div class="button_bar">
				<button class="common_button" onclick="help('');">
					帮助
				</button>  
				<button class="common_button" @click="query(1)" type="button">
					查询
				</button>
			</div>
			<table class="query_form_table">
				<tr>
					<th>
						权限文本
					</th>
					<td>
						<input type="text" v-model="sysRight.right_text">
					</td>
					<th>
						权限描述
					</th>
					<td>
						<input type="text" v-model="sysRight.right_tip">
					</td>
					<th>
						权限类型
					</th>
					<td>
						<select v-model="sysRight.right_text">
                            <option value="">--请选择父节点--</option>
                            <option v-for="m in sysMights">{{m.right_text}}</option>
</select>
					</td>
				</tr>
			</table>
			<br />
			<table class="query_form_table">
				<tr>
					<th>
						权限编号
					</th>
					<th>
						权限文本
					</th>
					<th>
						权限父节点
					</th>
					<th>
						权限类型
					</th>
					<th>
						权限描述
					</th>
					<th>
						权限操作
					</th>
				</tr>
				
					<tr v-for="m in mights">
						<td>
                            {{m.right_code}}
						</td>
						<td>
							{{m.right_text}}
						</td>
						<td>
                            {{m.right_parent_code}}
						</td>
						<td>
							{{m.right_icon}}
						</td>
						<td>
							{{m.right_tip}}
						</td>
						<td>
							<img
								@click="edit(m)"
								title="编辑" src="../../images/bt_edit.gif" class="op_button" />
							<img 
								@click="find(m)"
								title="查看" src="../../images/bt_deal.gif" class="op_button" />
							<img @click="del(m.right_code)" title="删除" src="../../images/bt_del.gif" class="op_button" />
						</td>
					</tr>
                <tr>
                    <th colspan="100" class="pager">
                        <div class="pager">
                            共{{pageInfo.total}}条记录
                            每页<input style="width: 30px;text-align: center" v-model="pageInfo.pageSize" />条
                            第<input v-model="pageInfo.pageNum" style="width: 30px;text-align: center"/>页/共{{pageInfo.pages}}页
                            <a @click="query(1)" href="javascript:;">第一页</a>
                            <a @click="query(pageInfo.pageNum-1)" href="javascript:;">上一页</a>
                            <a @click="query(pageInfo.pageNum+1)" href="javascript:;">下一页</a>
                            <a @click="query(pageInfo.pages)" href="javascript:;">最后一页</a>
                            转到<input v-model="pageInfo.pageNum" style="width: 30px;text-align: center"  />页
                            <button  @click="query(pageInfo.pageNum)"  type="button">GO</button>
                        </div>
                    </th>
                </tr>
			</table>
</form>
        </div>
        <script>
            var rights=new Vue({
                el:"#list",
                data:{
                    mights:[],
                    sysMights:[],
                    pageInfo:'',
                    sysRight:{
                        pageNum:'',
                        right_tip:'',
                        right_text:'',
                        right_icon:''
                    }
                },
                methods:{
                    query(num){
                        this.pageInfo.pageNum=num;
                        if(num<1){
                            this.pageInfo.pageNum=1;
                        }
                        if(num>this.pageInfo.pages)
                            this.pageInfo.pageNum=this.pageInfo.pages;

                        this.sysRight.pageNum=this.pageInfo.pageNum;
                        $.getJSON("/SysMight/queryPage",this.sysRight,function(json){
                            rights.mights=json.data.pageInfo.list;
                            rights.pageInfo=json.data.pageInfo;
                        });
                    },
                    edit(m){
                        sessionStorage.setItem("might",JSON.stringify(m));
                        location="/html/~right/right/edit.html";
                    },
                    find(m){
                        sessionStorage.setItem("might",JSON.stringify(m));
                        location="/html/~right/right/detail.html";
                    },
                    del(id){
                        var i =confirm("是否确认删除?");
                        if(i){
                            $.get("/SysMight/del/"+id,function (json) {
                                if(json.code==200){
                                    alert("删除成功！！");
                                    queryPage();
                                    return;
                                }else if(json.code==404){
                                    alert("无法删除,请先移除与其相关的内容！！");
                                    return;
                                }
                                alert("删除失败");
                            });
                        }

                    }
                },
                created(){
                    queryPage();
                    $.getJSON("/SysMight/query",{},function (json) {
                        rights.sysMights = json.data.list;
                    });
                }
            });
            function queryPage(){
                $.getJSON("/SysMight/queryPage",{},function(json){
                    rights.mights=json.data.pageInfo.list;
                    rights.pageInfo=json.data.pageInfo;
                });
            }
        </script>
	</body>
</html>
